import java.net.*;
import java.io.*;

public class Client3
{
	public static void main(String [] args)throws IOException 
	{
		//1. mo socket
		Socket mySocket = null;
		BufferedReader in = null;
		PrintWriter out = null;
		String data = "Hello, Server";
		try{
			mySocket = new Socket("127.0.0.1", 4560);
			in = new BufferedReader(new InputStreamReader(mySocket.getInputStream()));
			String data2 = in.readLine();
			System.out.println(data2);
			//Send to Server
			out = new PrintWriter(mySocket.getOutputStream(), true);
			out.println(data);
			out.flush();
			out.close();
			in.close();
		}catch(UnknownHostException e){
			System.err.println("Unknowning host");
			System.exit(1);
		}catch(IOException e){
			System.err.println("Cannot reach to the server");
			System.exit(1);
		}
		//2. dong socket
		mySocket.close();
	}
}